package org.example;



import org.example.utils.Fruit;
import org.example.utils.FruitFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @program: maven3
 * @description:
 * @author: zy
 * @create: 2025-09-09 11:22
 */
public class App3 {
    public static void main(String[] args) throws Exception {
        ApplicationContext ac=new AnnotationConfigApplicationContext(AppConfig3_factoryBean.class);
        //托管的是工厂,  getBean时取到的却是工厂生产的产品
        Fruit fruit= (Fruit) ac.getBean("fruitFactoryBean");
        System.out.println(fruit);
        //需求:如何才能获取到工厂
        FruitFactoryBean fruitFactoryBean= (FruitFactoryBean) ac.getBean("&fruitFactoryBean");
        System.out.println(fruitFactoryBean);
    }
}
